#include <iostream>
#include <time.h>
#include <thread>
#include <pybind11/pybind11.h>

void fun2(void)
{
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    int64_t start_us = ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
    std::cout << "fun2 start_us: " << start_us << std::endl;
    // do something
}

void fun1(void)
{
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    int64_t start_us = ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
    std::cout << "fun1 start_us: " << start_us << std::endl;
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    fun2();
}

PYBIND11_MODULE(monitor_time_test, m) {
    m.def("fun1", &fun1, "Test function 1");
}


